<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="/public/js/ag-grid-community.min.js"></script>
    <script src="/public/js/table/custom-tag.js"></script>
    <script src="/public/js/table/custom-link.js"></script>
</head>

<body>
    <div id="myGrid" style="height: 500px;width: 100%"></div>

    <script>
        // agGrid.provideGlobalGridOptions({
        //     theme: "legacy",
        // })
        // Grid Options: Contains all of the Data Grid configurations
        const gridOptions = {
            localeText: {
                noRowsToShow: '无显示行',
            },
            theme: agGrid.themeBalham, // 需要 小心 Dark Reader 浏览器插件之间的 css 样式冲突
            // Row Data: The data to be displayed.
            rowData: [
            ],
            // Column Definitions: Defines the columns to be displayed.
            columnDefs: [
                { field: "websiteUrlId", headerName: "网站url", },
                { field: "href", headerName: "href", cellRenderer: CustomLinkComponent },
                { field: "title", headerName: "标题", },
                { field: "tag", headerName: "标签", cellRenderer: CustomTagComponent },
                { field: "startTime", headerName: "开始时间", },
                { field: "endTime", headerName: "结束时间", },
                { field: "publishTime", headerName: "发布时间", },
                { field: "publisher", headerName: "发布人", },
                { field: "content", headerName: "内容", },
                { field: "newId", headerName: "新id", },
                { field: "createTime", headerName: "创建时间", },
                { field: "updateTime", headerName: "更新时间", },
                { field: "remark", headerName: "备注", },
            ]
        };

        // Your Javascript code to create the Data Grid
        const myGridElement = document.querySelector('#myGrid');
        let gridApi = agGrid.createGrid(myGridElement, gridOptions);


        fetch("http://192.168.4.50:3000/websiteUrls")
            .then(res => res.json())
            .then(res => {
                // gridApi.setGridOption('rowData', [
                //     { name: "张三", age: "18", sex: "男", address: "北京" },
                //     { name: "李四", age: "19", sex: "女", address: "上海" },
                //     { name: "王五", age: "20", sex: "男", address: "广州" },
                // ]);
                gridApi.setGridOption('rowData', res.data);
            })
    </script>
</body>

</html>